package drp.snowbell.cfg;

import java.io.File;

import drp.snowbell.util.StrHelper;


public class Location {
	public final static String ENTITY_CFG_DIR = "entities";
	public final static String MODILE_LIB_DIR = "lib";
	public final static String MODILE_LANG_DIR = "lang";

	public final static String APP_ROOT = System.getProperty("user.dir") + File.separator;
	public final static String CONFIG_FILE_EXT = ".xml";

	public final static String SYSTEM_CONFIG_PATH = APP_ROOT + "system" + CONFIG_FILE_EXT;

	public final static String CACHE_ROOT = APP_ROOT + "cache" + File.separator;
	public final static String MODULES_ROOT = APP_ROOT + "module" + File.separator;

	public final static String FULLTEXT_PATH = APP_ROOT + "fulltext" + File.separator;

	public final static String MODULE_CONFIG_FILE_NAME = "module" + CONFIG_FILE_EXT;

	/**
	 * 获取模块跟目录
	 * 
	 * @param moduleName
	 * @return
	 */
	public static String getModuleRoot(String moduleName) {
		return MODULES_ROOT + moduleName + File.separator;
	}

	/**
	 * 获取模块lib路径
	 * 
	 * @param moduleName
	 * @return
	 */
	public static String getModuleLibPath(String moduleName) {
		return getModuleRoot(moduleName) + MODILE_LIB_DIR + File.separator;
	}

	/**
	 * 获取语言包路径
	 * 
	 * @param moduleName
	 * @return
	 */
	public static String getModuleLangPath(String moduleName) {
		// 获取系统语言
		String lang = Config.get().getLanguage();
		if (StrHelper.isNullOrEmpty(lang)) {
			lang = "zh_CN";// 默认是简体中文
		}
		return getModuleLangPath(moduleName, lang);
	}

	public static String getModuleLangPath(String moduleName, String language) {
		return getModuleRoot(moduleName) + MODILE_LANG_DIR + File.separator + language + ".properties";// 是一个properties文件
	}

	/**
	 * 获取模块的实体配置路径
	 * 
	 * @param moduleName
	 * @return
	 */
	public static String getEntityConfigPath(String moduleName) {
		return getModuleRoot(moduleName) + Location.ENTITY_CFG_DIR + File.separator;
	}

}
